\doxysection{motor\+\_\+def.\+h}
\hypertarget{motor__def_8h_source}{}\label{motor__def_8h_source}\index{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/motor/motor\_def.h@{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/motor/motor\_def.h}}
\mbox{\hyperlink{motor__def_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ }
\DoxyCodeLine{00011\ }
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#ifndef\ MOTOR\_DEF\_H}}
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#define\ MOTOR\_DEF\_H}}
\DoxyCodeLine{00014\ }
\DoxyCodeLine{00015\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{controller_8h}{controller.h}}"{}}}
\DoxyCodeLine{00016\ \textcolor{preprocessor}{\#include\ "{}stdint.h"{}}}
\DoxyCodeLine{00017\ }
\DoxyCodeLine{00018\ \textcolor{preprocessor}{\#define\ LIMIT\_MIN\_MAX(x,\ min,\ max)\ (x)\ =\ (((x)\ <=\ (min))\ ?\ (min)\ :\ (((x)\ >=\ (max))\ ?\ (max)\ :\ (x)))}}
\DoxyCodeLine{00019\ }
\DoxyCodeLine{00024\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00025\ \{}
\DoxyCodeLine{00026\ \ \ \ \ OPEN\_LOOP\ =\ 0b0000,}
\DoxyCodeLine{00027\ \ \ \ \ CURRENT\_LOOP\ =\ 0b0001,}
\DoxyCodeLine{00028\ \ \ \ \ SPEED\_LOOP\ =\ 0b0010,}
\DoxyCodeLine{00029\ \ \ \ \ ANGLE\_LOOP\ =\ 0b0100,}
\DoxyCodeLine{00030\ }
\DoxyCodeLine{00031\ \ \ \ \ \textcolor{comment}{//\ only\ for\ checking}}
\DoxyCodeLine{00032\ \ \ \ \ SPEED\_AND\_CURRENT\_LOOP\ =\ 0b0011,}
\DoxyCodeLine{00033\ \ \ \ \ ANGLE\_AND\_SPEED\_LOOP\ =\ 0b0110,}
\DoxyCodeLine{00034\ \ \ \ \ ALL\_THREE\_LOOP\ =\ 0b0111,}
\DoxyCodeLine{00035\ \}\ \mbox{\hyperlink{motor__def_8h_a306d656c63a2d986e7aff57a0526395d}{Closeloop\_Type\_e}};}
\DoxyCodeLine{00036\ }
\DoxyCodeLine{00037\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00038\ \{}
\DoxyCodeLine{00039\ \ \ \ \ FEEDFORWARD\_NONE\ =\ 0b00,}
\DoxyCodeLine{00040\ \ \ \ \ CURRENT\_FEEDFORWARD\ =\ 0b01,}
\DoxyCodeLine{00041\ \ \ \ \ SPEED\_FEEDFORWARD\ =\ 0b10,}
\DoxyCodeLine{00042\ \ \ \ \ CURRENT\_AND\_SPEED\_FEEDFORWARD\ =\ CURRENT\_FEEDFORWARD\ |\ SPEED\_FEEDFORWARD,}
\DoxyCodeLine{00043\ \}\ Feedfoward\_Type\_e;}
\DoxyCodeLine{00044\ }
\DoxyCodeLine{00045\ \textcolor{comment}{/*\ 反馈来源设定,若设为OTHER\_FEED则需要指定数据来源指针,详见Motor\_Controller\_s*/}}
\DoxyCodeLine{00046\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00047\ \{}
\DoxyCodeLine{00048\ \ \ \ \ MOTOR\_FEED\ =\ 0,}
\DoxyCodeLine{00049\ \ \ \ \ OTHER\_FEED,}
\DoxyCodeLine{00050\ \}\ Feedback\_Source\_e;}
\DoxyCodeLine{00051\ }
\DoxyCodeLine{00052\ \textcolor{comment}{/*\ 电机正反转标志\ */}}
\DoxyCodeLine{00053\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00054\ \{}
\DoxyCodeLine{00055\ \ \ \ \ MOTOR\_DIRECTION\_NORMAL\ =\ 0,}
\DoxyCodeLine{00056\ \ \ \ \ MOTOR\_DIRECTION\_REVERSE\ =\ 1}
\DoxyCodeLine{00057\ \}\ Motor\_Reverse\_Flag\_e;}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00059\ \textcolor{comment}{/*\ 反馈量正反标志\ */}}
\DoxyCodeLine{00060\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00061\ \{}
\DoxyCodeLine{00062\ \ \ \ \ FEEDBACK\_DIRECTION\_NORMAL\ =\ 0,}
\DoxyCodeLine{00063\ \ \ \ \ FEEDBACK\_DIRECTION\_REVERSE\ =\ 1}
\DoxyCodeLine{00064\ \}\ Feedback\_Reverse\_Flag\_e;}
\DoxyCodeLine{00065\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00066\ \{}
\DoxyCodeLine{00067\ \ \ \ \ MOTOR\_STOP\ =\ 0,}
\DoxyCodeLine{00068\ \ \ \ \ MOTOR\_ENALBED\ =\ 1,}
\DoxyCodeLine{00069\ \}\ Motor\_Working\_Type\_e;}
\DoxyCodeLine{00070\ }
\DoxyCodeLine{00071\ \textcolor{comment}{/*\ 电机控制设置,包括闭环类型,反转标志和反馈来源\ */}}
\DoxyCodeLine{00072\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00073\ \{}
\DoxyCodeLine{00074\ \ \ \ \ \mbox{\hyperlink{motor__def_8h_a306d656c63a2d986e7aff57a0526395d}{Closeloop\_Type\_e}}\ outer\_loop\_type;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 最外层的闭环,未设置时默认为最高级的闭环}}
\DoxyCodeLine{00075\ \ \ \ \ \mbox{\hyperlink{motor__def_8h_a306d656c63a2d986e7aff57a0526395d}{Closeloop\_Type\_e}}\ close\_loop\_type;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 使用几个闭环(串级)}}
\DoxyCodeLine{00076\ \ \ \ \ Motor\_Reverse\_Flag\_e\ motor\_reverse\_flag;\ \ \ \ \ \ \ \textcolor{comment}{//\ 是否反转}}
\DoxyCodeLine{00077\ \ \ \ \ Feedback\_Reverse\_Flag\_e\ feedback\_reverse\_flag;\ \textcolor{comment}{//\ 反馈是否反向}}
\DoxyCodeLine{00078\ \ \ \ \ Feedback\_Source\_e\ angle\_feedback\_source;\ \ \ \ \ \ \ \textcolor{comment}{//\ 角度反馈类型}}
\DoxyCodeLine{00079\ \ \ \ \ Feedback\_Source\_e\ speed\_feedback\_source;\ \ \ \ \ \ \ \textcolor{comment}{//\ 速度反馈类型}}
\DoxyCodeLine{00080\ \ \ \ \ Feedfoward\_Type\_e\ feedforward\_flag;\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 前馈标志}}
\DoxyCodeLine{00081\ }
\DoxyCodeLine{00082\ \}\ \mbox{\hyperlink{struct_motor___control___setting__s}{Motor\_Control\_Setting\_s}};}
\DoxyCodeLine{00083\ }
\DoxyCodeLine{00084\ \textcolor{comment}{/*\ 电机控制器,包括其他来源的反馈数据指针,3环控制器和电机的参考输入*/}}
\DoxyCodeLine{00085\ \textcolor{comment}{//\ 后续增加前馈数据指针}}
\DoxyCodeLine{00086\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00087\ \{}
\DoxyCodeLine{00088\ \ \ \ \ \textcolor{keywordtype}{float}\ *other\_angle\_feedback\_ptr;\ \textcolor{comment}{//\ 其他反馈来源的反馈数据指针}}
\DoxyCodeLine{00089\ \ \ \ \ \textcolor{keywordtype}{float}\ *other\_speed\_feedback\_ptr;}
\DoxyCodeLine{00090\ \ \ \ \ \textcolor{keywordtype}{float}\ *speed\_feedforward\_ptr;}
\DoxyCodeLine{00091\ \ \ \ \ \textcolor{keywordtype}{float}\ *current\_feedforward\_ptr;}
\DoxyCodeLine{00092\ }
\DoxyCodeLine{00093\ \ \ \ \ \mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}}\ current\_PID;}
\DoxyCodeLine{00094\ \ \ \ \ \mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}}\ speed\_PID;}
\DoxyCodeLine{00095\ \ \ \ \ \mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}}\ angle\_PID;}
\DoxyCodeLine{00096\ }
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{keywordtype}{float}\ pid\_ref;\ \textcolor{comment}{//\ 将会作为每个环的输入和输出顺次通过串级闭环}}
\DoxyCodeLine{00098\ \}\ \mbox{\hyperlink{struct_motor___controller__s}{Motor\_Controller\_s}};}
\DoxyCodeLine{00099\ }
\DoxyCodeLine{00100\ \textcolor{comment}{/*\ 电机类型枚举\ */}}
\DoxyCodeLine{00101\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00102\ \{}
\DoxyCodeLine{00103\ \ \ \ \ MOTOR\_TYPE\_NONE\ =\ 0,}
\DoxyCodeLine{00104\ \ \ \ \ GM6020,}
\DoxyCodeLine{00105\ \ \ \ \ M3508,}
\DoxyCodeLine{00106\ \ \ \ \ M2006,}
\DoxyCodeLine{00107\ \ \ \ \ LK9025,}
\DoxyCodeLine{00108\ \ \ \ \ HT04,}
\DoxyCodeLine{00109\ \}\ Motor\_Type\_e;}
\DoxyCodeLine{00110\ }
\DoxyCodeLine{00116\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00117\ \{}
\DoxyCodeLine{00118\ \ \ \ \ \textcolor{keywordtype}{float}\ *other\_angle\_feedback\_ptr;\ \textcolor{comment}{//\ 角度反馈数据指针,注意电机使用total\_angle}}
\DoxyCodeLine{00119\ \ \ \ \ \textcolor{keywordtype}{float}\ *other\_speed\_feedback\_ptr;\ \textcolor{comment}{//\ 速度反馈数据指针,单位为angle\ per\ sec}}
\DoxyCodeLine{00120\ }
\DoxyCodeLine{00121\ \ \ \ \ \textcolor{keywordtype}{float}\ *speed\_feedforward\_ptr;\ \ \ \textcolor{comment}{//\ 速度前馈数据指针}}
\DoxyCodeLine{00122\ \ \ \ \ \textcolor{keywordtype}{float}\ *current\_feedforward\_ptr;\ \textcolor{comment}{//\ 电流前馈数据指针}}
\DoxyCodeLine{00123\ }
\DoxyCodeLine{00124\ \ \ \ \ \mbox{\hyperlink{struct_p_i_d___init___config__s}{PID\_Init\_Config\_s}}\ current\_PID;}
\DoxyCodeLine{00125\ \ \ \ \ \mbox{\hyperlink{struct_p_i_d___init___config__s}{PID\_Init\_Config\_s}}\ speed\_PID;}
\DoxyCodeLine{00126\ \ \ \ \ \mbox{\hyperlink{struct_p_i_d___init___config__s}{PID\_Init\_Config\_s}}\ angle\_PID;}
\DoxyCodeLine{00127\ \}\ \mbox{\hyperlink{struct_motor___controller___init__s}{Motor\_Controller\_Init\_s}};}
\DoxyCodeLine{00128\ }
\DoxyCodeLine{00129\ \textcolor{comment}{/*\ 用于初始化CAN电机的结构体,各类电机通用\ */}}
\DoxyCodeLine{00130\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00131\ \{}
\DoxyCodeLine{00132\ \ \ \ \ \mbox{\hyperlink{struct_motor___controller___init__s}{Motor\_Controller\_Init\_s}}\ controller\_param\_init\_config;}
\DoxyCodeLine{00133\ \ \ \ \ \mbox{\hyperlink{struct_motor___control___setting__s}{Motor\_Control\_Setting\_s}}\ controller\_setting\_init\_config;}
\DoxyCodeLine{00134\ \ \ \ \ Motor\_Type\_e\ motor\_type;}
\DoxyCodeLine{00135\ \ \ \ \ \mbox{\hyperlink{struct_c_a_n___init___config__s}{CAN\_Init\_Config\_s}}\ can\_init\_config;}
\DoxyCodeLine{00136\ \}\ \mbox{\hyperlink{struct_motor___init___config__s}{Motor\_Init\_Config\_s}};}
\DoxyCodeLine{00137\ }
\DoxyCodeLine{00138\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ !MOTOR\_DEF\_H}}

\end{DoxyCode}
